package com.fdw.smartexam_system.system.service.impl;

import com.fdw.smartexam_system.system.model.Question;
import com.fdw.smartexam_system.system.repository.QuestionRepository;
import com.fdw.smartexam_system.system.service.QuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

@Service
public class QuestionServiceImpl implements QuestionService {

    @Autowired
    private QuestionRepository repository;

    public Question createQuestion(Question question) {
        // TODO: 实现业务逻辑
        return repository.save(question);
    }

    public Question updateQuestion(Long id, Question questionDetails) {
        // TODO: 实现业务逻辑
        return repository.save(questionDetails);
    }

    public boolean deleteQuestion(Long id) {
        // TODO: 实现业务逻辑
        repository.deleteById(id);
        return true;
    }

    public List<Question> getAllQuestions() {
        // TODO: 实现业务逻辑
        return repository.findAll();
    }

    public Question getQuestionById(Long id) {
        // TODO: 实现业务逻辑
        Optional<Question> byId = repository.findById(id);
        return byId.get();
    }
}
